package com.zhuqi.dynamic;


import java.io.Serializable;

/**
 * Copyright (C) 2014-2019 天津紫藤科技股份有限公司. Co. Ltd. All Rights Reserved.
 *
 * @author sun
 * @version 1.0
 * @description
 * @module
 * @date 2019/1/31
 */
public class OutVoGlobal implements Serializable {
    public OutVoGlobal() {
    }

    /**
     * 系统状态
     */
    private String code;
    /**
     * 系统返回信息
     */
    private String info;
    /**
     * 返回数据
     */
    private Object data;

    private Long total;

    public String getCode() {
        return code;
    }

    public Object getData() {
        return data;
    }

    public String getInfo() {
        return info;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        if (total == null) {
            this.total = 0L;
        }else {
            this.total = total;
        }
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public void setCode(String code) {
        this.code = code;
    }


    @Override
    public String toString() {
        return "code:" + this.code + " info:" + this.info + " data:" + this.data;
    }


    /**
     * 处理失败，并返回错误信息
     *
     * @param msg 错误信息
     * @return rest接口返回的实体
     * @author fangzc
     */
    public static OutVoGlobal fail(String msg) {
        OutVoGlobal result = new OutVoGlobal();
        result.setCode("500");
        result.setInfo(msg);
        return result;
    }

    /**
     * 处理失败，并返回错误信息
     *
     * @param msg 错误信息
     * @return rest接口返回的实体
     * @author fangzc
     */
    public static OutVoGlobal fail(String code, String msg) {
        OutVoGlobal result = new OutVoGlobal();
        result.setCode(code);
        result.setInfo(msg);
        return result;
    }

    /**
     * 处理失败，并返回错误信息
     *
     * @param msg 错误信息
     * @return rest接口返回的实体
     * @author fangzc
     */
    public static OutVoGlobal fail(String code, String msg, Object data) {
        OutVoGlobal result = new OutVoGlobal();
        result.setCode(code);
        result.setInfo(msg);
        result.setData(data);
        return result;
    }

}
